//
//  GuaranteeView.m
//  YiShangPin
//
//  Created by 衣尚品1 on 15/3/20.
//  Copyright (c) 2015年 yishangpin2. All rights reserved.
//

#import "GuaranteeView.h"
#import "AppDelegate.h"

@implementation GuaranteeView

// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
    
    AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    
    UIImageView *iconImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, delegate.width/4, delegate.width/4)];
    iconImage.image = [UIImage imageNamed:@"clearIcon.png"];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(delegate.width/5, 50, delegate.width/3*2+20, 50)];
    label.text = @"We guarantee a sage and secure shopping experience so you never have to worry.";
    label.textColor = [UIColor grayColor];
    label.font = [UIFont fontWithName:@"TimesNewRomanPS-ItalicMT" size:16];
    label.numberOfLines = 0;
    label.lineBreakMode = NSLineBreakByWordWrapping;
    
    CGSize size = [label.text boundingRectWithSize:CGSizeMake(delegate.width/3*2+20, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:label.font,NSFontAttributeName, nil] context:nil].size;
    
    UIView *backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 15, delegate.width, delegate.width/4-10)];
    backgroundView.backgroundColor = [UIColor colorWithRed:184.f/255 green:190.f/255 blue:194.f/255 alpha:0.3];
    
    label.frame = CGRectMake(delegate.width/4, (backgroundView.frame.size.height-size.height)/2, size.width, size.height);
    
    [backgroundView addSubview:label];
    [self addSubview:backgroundView];
    [self addSubview:iconImage];
}


@end
